<template>
  <TopNavBar title="订单详情" type="back" />
  <div class="aiarb-order-detail-page">
    <div class="order-detail-card">
      <div class="order-detail-header">
        <div class="order-detail-symbol">BTC/USDT</div>
        <div class="order-detail-id">2025031200205106460000879489774</div>
        <div class="order-detail-status">已完成</div>
      </div>
      <div class="order-detail-row">
        <span class="order-detail-label">开仓时间</span>
        <span class="order-detail-value">2025-03-12 00:20:51</span>
      </div>
      <div class="order-detail-row">
        <div>
          <img class="order-ex-logo" src="https://xinyuanimg-c.oss-cn-hongkong.aliyuncs.com/public/949bc8d1f5d1491d8f2d57e07cf553e2.png" alt="Crypto" />
          <span class="order-detail-label">Crypto价格</span>
        </div>
        <span class="order-detail-value">81,034.82 USD</span>
      </div>
      <div class="order-detail-row">
        <span class="order-detail-label">代币数量</span>
        <span class="order-detail-value">0.001234</span>
      </div>
      <div class="order-detail-row">
        <span class="order-detail-label">操作</span>
        <span class="order-detail-op">看涨</span>
      </div>
      <div class="order-detail-row">
        <div>
          <img class="order-ex-logo" src="https://xinyuanimg-c.oss-cn-hongkong.aliyuncs.com/public/bc2525ef9de3407f970043b98df9e2d5.png" alt="Binance" />
          <span class="order-detail-label">Binance价格</span>
        </div>
        <span class="order-detail-value">80,694.463436 USD</span>
      </div>
      <div class="order-detail-row">
        <span class="order-detail-label">获利</span>
        <span class="order-detail-profit profit-down">-0.29 USD</span>
      </div>
      <div class="order-detail-row">
        <span class="order-detail-label">手续费</span>
        <span class="order-detail-value">0 USD</span>
      </div>

      <div class="order-detail-list">
        <div class="order-detail-list-item" v-for="(item, idx) in detailList" :key="idx" @click="toggleExpand(idx)">
          <div style="display: flex;align-items: center;justify-content: space-between;">
            <span class="order-detail-list-index">#{{ idx + 1 }}</span>
          <span class="order-detail-list-time">{{ item.time }}</span>
          <div class="order-detail-list-right">
            <span class="order-detail-list-profit" :class="item.profit > 0 ? 'profit-up' : 'profit-down'">
              {{ item.profit > 0 ? '+' : '' }}{{ item.profit }} USD
            </span>
            <svg 
              data-v-664dea44="" 
              width="24" 
              height="24" 
              viewBox="0 0 24 24" 
              fill="none" 
              xmlns="http://www.w3.org/2000/svg" 
              class="arrow-icon"
              :class="{ 'expanded': expandedItems[idx] }"
            >
              <g data-v-664dea44="" clip-path="url(#clip0_6394_7387)">
                <path data-v-664dea44="" d="M7 10L12 15L17 10H7Z" fill="var(--bg-color-arrow)"></path>
              </g>
              <defs data-v-664dea44="">
                <clipPath data-v-664dea44="" id="clip0_6394_7387">
                  <rect data-v-664dea44="" width="24" height="24" fill="transparent"></rect>
                </clipPath>
              </defs>
            </svg>
          </div>
          </div>
          
          <!-- 展开的交易详情 -->
          <div v-if="expandedItems[idx]" class="order-detail-expanded">
            <div class="transaction-sell">
              <div class="transaction-button sell">卖出BTC</div>
              <div class="transaction-details">
                <div class="transaction-row">
                  <div class="transaction-col">
                    <div class="transaction-label">价格</div>
                    <div class="transaction-value">118,757.36</div>
                  </div>
                  <div class="transaction-col">
                    <div class="transaction-label">时间</div>
                    <div class="transaction-value">2025-07-28<br>13:03:05</div>
                  </div>
                  <div class="transaction-col">
                    <div class="transaction-label">利润</div>
                    <div class="transaction-value profit-down">-0.48 USD</div>
                  </div>
                </div>
              </div>
            </div>
            <div class="transaction-buy">
              <div class="transaction-button buy">买入BTC</div>
              <div class="transaction-details">
                <div class="transaction-row">
                  <div class="transaction-col">
                    <div class="transaction-label">价格</div>
                    <div class="transaction-value">119,272.94</div>
                  </div>
                  <div class="transaction-col">
                    <div class="transaction-label">时间</div>
                    <div class="transaction-value">2025-07-28<br>13:03:00</div>
                  </div>
                  <div class="transaction-col">
                    <div class="transaction-label">代币数量</div>
                    <div class="transaction-value profit-up">0.000931</div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <button class="order-detail-refresh">刷新</button>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const detailList = [
  { time: '2025-03-12 00:21:15', profit: -0.42 },
  { time: '2025-03-12 00:21:05', profit: 0.09 },
  { time: '2025-03-12 00:20:51', profit: -0.04 },
]

const expandedItems = ref({})

const toggleExpand = (index) => {
  expandedItems.value[index] = !expandedItems.value[index]
}
</script>

<style scoped>
.aiarb-order-detail-page {
  background: #f7f8fa;
  min-height: 100vh;
  padding: 0 0 32px 0;
}
.order-detail-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 2px 8px 0 rgba(0,0,0,0.04);
  padding: 20px 18px 18px 18px;
  margin: 18px 12px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.order-detail-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}
.order-detail-symbol {
  font-size: 18px;
  font-weight: 700;
  color: #222;
}
.order-detail-id {
  font-size: 12px;
  color: #b0b0b0;
  margin-top: 2px;
}
.order-detail-status {
  font-size: 15px;
  color: #00c693;
  font-weight: 600;
  margin-top: 2px;
}
.order-detail-row {
  display: flex;
  align-items: center;
  font-size: 14px;
  margin-bottom: 2px;
  justify-content: space-between;
}
.order-detail-label {
  color: #222;
  min-width: 80px;
}
.order-detail-value {
  color: #222;
  margin-left: 8px;
  font-weight: 500;
}
.order-detail-op {
  color: #00c693;
  font-weight: 600;
  margin-left: 8px;
}
.order-ex-logo {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  margin-right: 6px;
  background: #f6f8fa;
  border: 1px solid #eee;
}
.order-detail-profit {
  margin-left: 8px;
  font-weight: 600;
}
.profit-up {
  color: #00c693;
}
.profit-down {
  color: #ff4d4f;
}
.order-detail-list {
  background: #fff;
  border-radius: 12px;
}
.order-detail-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-direction: column;
  border-bottom: 1px solid #f2f2f2;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s;
}
.order-detail-list-item:hover {
  background-color: #f8f9fa;
}
.order-detail-list-item:last-child {
  border-bottom: none;
}
.order-detail-list-index {
  color: #b0b0b0;
  min-width: 32px;
}
.order-detail-list-time {
  color: #222;
  flex: 1;
  margin-left: 8px;
}
.order-detail-list-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.order-detail-list-profit {
  min-width: 80px;
  text-align: right;
  font-weight: 600;
}
.arrow-icon {
  transform: rotate(-90deg);
  transition: transform 0.3s ease;
  --bg-color-arrow: #999;
  flex-shrink: 0;
}
.arrow-icon.expanded {
  transform: rotate(0deg);
}

.order-detail-expanded {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
}
.transaction-sell,
.transaction-buy {
  margin-bottom: 12px;
}
.transaction-sell:last-child,
.transaction-buy:last-child {
  margin-bottom: 0;
}
.transaction-button {
  width: 70px;
  padding: 3px  6px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  text-align: center;
  margin-bottom: 8px;
}
.transaction-button.sell {
  background: #ff4d4f;
}
.transaction-button.buy {
  background: #00c693;
}
.transaction-details {
  padding: 0 4px;
}
.transaction-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.transaction-col {
  flex: 1;
  text-align: center;
}
.transaction-col:nth-child(1) {
  text-align: left;
}
.transaction-col:nth-child(3) {
  text-align: right;
}
.transaction-label {
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
}
.transaction-value {
  font-size: 13px;
  color: #222;
  font-weight: 500;
  line-height: 1.4;
}
.order-detail-refresh {
  margin: 24px auto 0 auto;
  display: block;
  width: 80%;
  background: #fff;
  color: #222;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  padding: 10px 0;
  box-shadow: 0 2px 8px 0 rgba(0,0,0,0.04);
  cursor: pointer;
  transition: background 0.2s;
}
.order-detail-refresh:active {
  background: #f2f2f2;
}
</style> 